<?php
/**
 * Created by PhpStorm.
 * User: hengliu
 * Date: 2019/7/8
 * Time: 3:06 PM
 */

// 第1组数据

$partial = "3366.1:7:3366.8:9:3366:6:3368:8";
//$partial = '{"table":"futures/depth","action":"partial","data":[{"instrument_id":"DASH-USDT","asks":[["80.25","8.814507","3"],["80.26","11.73","1"],["80.27","4.581906","2"],["80.29","41.2807","2"],["80.3","202.493356","11"],["80.36","19.598357","3"],["80.37","1.78","1"],["80.38","18","1"],["80.4","63.414","2"],["80.47","59.944657","2"],["80.5","0.251331","1"],["80.52","45","1"],["80.53","3.401242","1"],["80.61","3.769","1"],["80.62","301.366758","3"],["80.82","4","1"],["80.86","5.363","1"],["80.87","286.41","1"],["80.94","0.278843","1"],["80.96","6.285678","1"],["80.99","9.068862","1"],["81","5.265205","3"],["81.01","8.227162","2"],["81.12","1.156","1"],["81.13","0.00242","1"],["81.16","7.433474","1"],["81.3","1.345","2"],["81.4","20.546","2"],["81.54","0.799","1"],["81.64","13.00242","2"],["81.73","117.7","1"],["81.79","0.278843","1"],["81.8","0.143914","1"],["81.97","4.894327","1"],["81.98","1.0989","1"],["82","4.598","3"],["82.14","0.00242","1"],["82.19","2.289","1"],["82.2","1.2316","1"],["82.31","6.230529","1"],["82.4","24.887796","1"],["82.49","58.36","1"],["82.5","5.779463","2"],["82.64","0.278843","1"],["82.65","0.00242","1"],["82.69","7.670402","1"],["83","2.1","2"],["83.16","0.00242","1"],["83.3","0.143914","1"],["83.49","0.278843","1"],["83.65","6","1"],["83.66","0.00242","1"],["84","113.808912","7"],["84.1","0.143914","1"],["84.17","0.00242","1"],["84.33","0.278843","1"],["84.68","0.00242","1"],["84.8","0.96","1"],["84.9","0.143914","1"],["84.94","68","1"],["85","0.59925","2"],["85.18","0.281263","2"],["85.63","50","1"],["85.69","0.00242","1"],["85.7","0.143914","1"],["85.8","0.2","1"],["86","144.137383","4"],["86.03","0.278843","1"],["86.2","0.00242","1"],["86.32","4.696216","1"],["86.4","0.143914","1"],["86.5","0.238461","1"],["86.58","0.2","1"],["86.68","58.282136","1"],["86.7","0.00242","1"],["86.88","12.402487","2"],["86.94","68","1"],["87","26.384433","3"],["87.2","0.143914","1"],["87.21","0.00242","1"],["87.38","53.110427","1"],["87.42","0.000004","1"],["87.5","1","1"],["87.55","29.982","1"],["87.72","0.00242","1"],["87.73","0.278843","1"],["87.8","0.2","1"],["87.99","0.011005","1"],["88","23.040185","7"],["88.2","0.2","1"],["88.23","0.00242","1"],["88.3","100","1"],["88.33","150","1"],["88.38","48.607454","1"],["88.44","0.283526","1"],["88.5","1","1"],["88.58","0.278843","1"],["88.68","13","1"],["88.73","0.00242","1"],["88.8","0.143914","1"],["88.9","1","1"],["89","69.847826","6"],["89.24","0.00242","1"],["89.43","0.278843","1"],["89.6","0.143914","1"],["89.7","6.132396","1"],["89.75","0.00242","1"],["89.8","100","1"],["89.83","130.68604","1"],["90","53.544827","9"],["90.25","0.00242","1"],["90.28","0.278843","1"],["90.3","0.143914","1"],["90.33","0.387997","1"],["90.76","0.00242","1"],["91.1","0.143914","1"],["91.13","0.278843","1"],["91.27","0.00242","1"],["91.77","0.00242","1"],["91.78","0.50324","1"],["91.88","0.2","1"],["91.9","0.143914","1"],["91.98","0.278843","1"],["92","44.105216","2"],["92.28","0.00242","1"],["92.7","0.143914","1"],["92.79","0.00242","1"],["92.83","0.278843","1"],["93","0.1","1"],["93.29","0.00242","1"],["93.5","0.143914","1"],["93.56","48.607454","1"],["93.67","0.278843","1"],["93.8","0.00242","1"],["94.2","0.143914","1"],["94.31","0.00242","1"],["94.52","0.278843","1"],["94.6","11.841718","1"],["94.82","0.00242","1"],["95","65.760473","11"],["95.32","0.00242","1"],["95.37","0.278843","1"],["95.58","0.2","1"],["95.8","0.143914","1"],["95.83","0.00242","1"],["96","6.321769","3"],["96.22","0.278843","1"],["96.34","0.00242","1"],["96.6","0.143914","1"],["96.84","0.00242","1"],["97","4.987651","1"],["97.07","0.278843","1"],["97.35","0.00242","1"],["97.4","0.143914","1"],["97.86","0.00242","1"],["97.92","0.278843","1"],["98","0.164617","2"],["98.1","0.143914","1"],["98.36","0.00242","1"],["98.77","0.278843","1"],["98.87","0.00242","1"],["98.88","1.5","1"],["98.9","0.143914","1"],["99","27.131918","4"],["99.18","0.23","1"],["99.38","0.00242","1"],["99.62","0.278843","1"],["99.67","14.677918","1"],["99.7","0.143914","1"],["99.89","0.00242","1"],["100","174.424568","5"],["100.47","0.278843","1"],["100.5","0.143914","1"],["101.2","0.143914","1"],["101.32","0.278843","1"],["101.5","0.1","1"],["102","9.218081","3"],["102.16","0.278843","1"],["102.8","0.143914","1"],["103","0.864121","1"],["103.01","0.278843","1"],["103.58","0.233095","1"],["103.6","0.143914","1"],["103.86","0.278843","1"],["104.4","0.143914","1"],["104.6","46","1"],["104.71","0.278843","1"],["105","0.13","2"],["105.1","0.143914","1"],["105.56","0.278843","1"],["105.9","0.143914","1"],["106.41","0.278843","1"],["106.6","0.71","1"],["106.7","0.143914","1"],["107.26","0.278843","1"],["107.5","0.143914","1"],["108","2.704054","2"],["108.11","0.278843","1"],["108.3","0.143914","1"],["108.96","0.278843","1"],["109","0.238914","2"],["109.5","0.026663","1"],["109.8","0.143914","1"],["109.81","0.278843","1"],["110","24.155889","6"],["110.6","0.143914","1"],["110.66","0.278843","1"],["111.1","0.023478","1"],["111.4","0.143914","1"],["111.5","0.278843","1"],["112.2","0.143914","1"],["112.33","0.625","1"],["112.35","0.278843","1"],["112.8","0.09","1"],["112.9","0.143914","1"],["113","0.79288","2"],["113.2","0.278843","1"],["113.7","0.143914","1"],["114.05","0.278843","1"],["114.5","0.143914","1"],["114.9","0.278843","1"],["115","0.05","1"],["115.3","0.143914","1"],["115.75","0.278843","1"],["116.1","0.143914","1"],["116.6","0.278843","1"],["116.8","0.143914","1"],["117.45","0.278843","1"],["117.6","0.143914","1"],["118.3","0.278843","1"],["118.4","0.143914","1"],["119.15","0.278843","1"],["119.2","0.143914","1"],["120","0.922757","4"],["123","0.81","1"],["123.9","0.999","1"],["125","0.853335","2"],["126","0.260376","1"],["128","3","1"],["128.55","40","1"],["128.61","40","1"],["128.66","40","1"],["128.73","40","1"],["129.5","10","1"],["130","94.997821","9"],["131","0.280357","2"],["132","0.0999","1"],["133","1","1"],["134.9","8.541656","1"],["135","50.5495","3"],["136","0.813","1"],["138","10.178775","4"],["138.5","0.5","1"],["139","5.008541","1"],["139.8","0.1","1"],["140","36.020707","4"],["140.6","0.223875","1"],["141","21.554353","2"],["142","0.0896","1"],["142.68","10","1"],["144.5","0.512654","1"],["145","0.0981","1"],["145.5","26.426977","1"],["145.6","10.953372","1"],["147.7","0.021197","1"],["148.5","0.303406","1"],["149.9","73.134346","1"],["150","73.58562","6"],["150.9","4.394349","1"],["153.2","0.721271","1"],["154.8","19","1"],["156","10.991708","1"],["156.4","100","1"],["156.5","110","1"],["156.6","120","1"],["156.7","130","1"],["156.8","140","1"],["156.9","150","1"],["157","160.081834","3"],["157.2","170","1"],["157.6","180","1"],["157.8","66.490339","1"],["158.8","9.99","1"],["159.9","0.655758","1"],["160","1.2376","3"],["160.7","0.999","1"],["163.2","4.995","1"],["164","0.024913","1"],["165.4","2.003764","1"],["165.5","0.607431","1"],["168.67","0.035448","1"],["168.8","3.68906","2"],["170","9.488118","4"],["172.2","0.1","1"],["172.26","81.724667","1"],["173.7","2.658525","1"],["178.5","9.324416","1"],["178.8","0.209423","1"],["180","51.673691","3"],["182.9","19","1"],["186","10","1"],["188","5.1705","2"],["188.8","114.802859","2"],["189.8","6","1"],["190","0.608803","2"],["192.1","0.026697","1"],["196","0.359915","1"],["198.8","0.09958","1"],["199","1.059843","2"],["200","7.994215","6"],["201.1","0.079521","1"],["204","19","1"],["213.9","0.026299","1"],["214.9","0.028961","1"],["215.2","0.028474","1"],["217.3","0.170247","1"],["220.7","0.024817","1"],["221.2","0.024715","1"],["240","2.192991","1"],["245","16.046909","1"],["246","1","1"],["253.71","0.05","1"],["258.86","16.830617","1"],["258.88","107.146905","1"],["258.93","4.135088","1"],["258.94","5.994","1"],["260","2.051657","3"],["267.4","13.138961","1"],["269.13","0.012404","1"],["277","0.236488","1"],["280","3.604423","1"],["285","1.310821","1"],["287.2364","0.0811","1"],["300","2.375283","2"],["312.4","0.029171","1"],["313.2","0.044259","1"],["322.1","0.024512","1"],["324.8","0.119831","1"],["327.5","0.023475","1"],["369.6","57.957199","1"],["370","0.189091","1"],["395","0.400551","1"],["399.9999","0.049925","1"],["400","0.5","1"],["404.2734","0.1986","1"],["450","3.112184","2"],["475","1.199428","1"],["479.9999","0.3994","1"],["498.9998","0.063844","1"],["499.9999","0.124813","1"],["500","1.759093","2"],["520","0.253955","3"],["530","0.314802","1"],["555.5","1.998","1"],["560","5.069937","1"],["599.9999","0.063655","1"],["600","50.51065","1"],["610","0.01","1"],["650","0.03","1"],["699.9999","0.253217","1"],["704","0.03","1"],["720","1.984386","1"],["730","5.710593","1"],["735.9999","0.9985","1"],["750","0.089747","2"],["774.85","0.001","1"],["777","0.0775","1"],["800","42.126877","3"],["820.43","2.675089","1"],["888","9.99","1"],["900","0.6","1"],["950","0.06","1"],["999.9","1.220323","1"],["1000","9.210226","4"],["1016.14","0.0802","1"],["1050","2.24375","1"],["1099","0.0558","1"],["1120","0.31167631","2"],["1200","1.279558","3"],["1200.04","27.776688","1"],["1287.7777","0.1321","1"],["1300","5.911316","2"],["1350","0.2","1"],["1400","8.2","1"],["1430","170.271666","2"],["1487.7777","0.179","1"],["1500","0.65182","4"],["1524.212","0.02676792","1"],["1550","2.24375","1"],["1600","0.515502","1"],["1622.2","0.9756","1"],["1680","0.83823488","2"],["1699.9999","0.6304","1"],["1700","1.75044523","1"],["1780","0.503219","1"],["1800","3.24225","2"],["1853","1.00008389","1"],["1900","9.0442","1"],["1980","0.60823189","1"],["1987.7777","0.08823","1"],["2000","6.004968","2"],["2050","2.24375","1"]],"bids":[["80.14","0.18","1"],["80.13","6.501123","1"],["80.11","19.657531","2"],["80.1","7.283174","2"],["80.08","12.6","1"],["80.06","2.801346","1"],["80.04","33.013334","3"],["80.01","19.78","2"],["80","48.198266","6"],["79.99","7.541","1"],["79.91","59.82","1"],["79.9","45.376487","3"],["79.86","45","1"],["79.83","3.769","1"],["79.77","295.07","1"],["79.76","3.308108","1"],["79.63","4.598","1"],["79.62","0.038","1"],["79.61","0.00242","1"],["79.53","4.164626","1"],["79.51","0.311488","1"],["79.44","3.115511","1"],["79.4","0.143914","1"],["79.37","286.41","1"],["79.34","9.25105","2"],["79.31","8.823778","1"],["79.25","27.066246","1"],["79.24","0.278843","1"],["79.22","4","1"],["79.2","4.202","1"],["79.1","0.00242","1"],["78.99","8.33223","1"],["78.77","184.438","2"],["78.7","0.143914","1"],["78.59","0.00242","1"],["78.39","0.278843","1"],["78.37","0.641","1"],["78.26","0.089957","1"],["78.09","0.00242","1"],["78.06","2","1"],["78","7.550058","2"],["77.96","117.7","1"],["77.9","0.143914","1"],["77.8","0.090488","1"],["77.76","21.085842","1"],["77.62","58.36","1"],["77.58","0.00242","1"],["77.54","0.278843","1"],["77.4","27.53438","1"],["77.1","23.224109","2"],["77.07","0.00242","1"],["77","1","1"],["76.8","23.770156","1"],["76.69","0.278843","1"],["76.6","50","1"],["76.57","0.00242","1"],["76.49","6.367398","1"],["76.46","35","1"],["76.3","26.886561","2"],["76.06","2.00242","2"],["76","2.5","3"],["75.84","0.278843","1"],["75.68","60","1"],["75.55","0.00242","1"],["75.5","0.143914","1"],["75.48","100","1"],["75.44","58.27","1"],["75.04","0.00242","1"],["75","15.303323","7"],["74.8","0.143914","1"],["74.54","0.00242","1"],["74.3","47.733782","2"],["74.1","26.012145","1"],["74.06","2","1"],["74.03","0.00242","1"],["74","1.143914","2"],["73.84","1.102994","1"],["73.52","0.00242","1"],["73.5","1.749827","1"],["73.3","50","1"],["73.2","0.143914","1"],["73.02","0.00242","1"],["73","11.369642","3"],["72.7","67.976731","1"],["72.51","0.00242","1"],["72.4","0.143914","1"],["72.1","5.988593","1"],["72","21.444831","4"],["71.78","28.221946","1"],["71.6","0.143914","1"],["71.56","57.198854","1"],["71.5","0.00242","1"],["70.99","0.00242","1"],["70.9","0.143914","1"],["70.48","0.00242","1"],["70.2","5.844108","1"],["70.1","0.143914","1"],["70","9.126525","3"],["69.98","0.00242","1"],["69.7","1.5","1"],["69.47","0.00242","1"],["69.3","0.143914","1"],["69","32.706271","2"],["68.96","0.00242","1"],["68.8","3","1"],["68.6","0.619388","1"],["68.5","0.143914","1"],["68.45","0.00242","1"],["67.95","0.00242","1"],["67.7","73.141082","2"],["67.5","8.024837","1"],["67.44","0.00242","1"],["67","1.143914","2"],["66.93","0.00242","1"],["66.43","0.00242","1"],["66.2","0.143914","1"],["66","82.115676","2"],["65.92","0.00242","1"],["65.41","0.00242","1"],["65.4","0.143914","1"],["65","0.6","2"],["64.91","0.00242","1"],["64.6","0.143914","1"],["64.4","0.00242","1"],["63.89","0.00242","1"],["63.8","0.143914","1"],["63.4","0.006135","1"],["63.39","0.00242","1"],["63.1","0.143914","1"],["62.88","0.00242","1"],["62.37","0.00242","1"],["62.3","0.143914","1"],["61.86","0.00242","1"],["61.8","1.7","1"],["61.5","46.143914","2"],["61.36","0.00242","1"],["60.85","0.00242","1"],["60.7","0.143914","1"],["60.5","1","1"],["60.34","0.00242","1"],["60.1","18.420849","1"],["60","10.62293","2"],["59.84","0.00242","1"],["59.33","0.00242","1"],["59","0.039068","1"],["58.82","0.00242","1"],["58.32","0.00242","1"],["57.81","0.00242","1"],["57.64","0.02","1"],["57.3","0.00242","1"],["57","0.054829","1"],["56.8","0.00242","1"],["56.29","0.00242","1"],["55.78","0.00242","1"],["55.58","11.95629","1"],["55.27","0.00242","1"],["55","13.669101","2"],["54.77","0.00242","1"],["54.6","2","1"],["54.26","0.00242","1"],["53.75","0.00242","1"],["53.25","0.00242","1"],["53","0.042895","1"],["52.74","0.00242","1"],["52.66","30.015","1"],["52.23","0.00242","1"],["51.8","5","1"],["51.73","0.00242","1"],["51.22","0.00242","1"],["50.71","0.00242","1"],["50.21","0.00242","1"],["50","43.565003","6"],["49.11","530.114857","1"],["46.5","5","1"],["45.5","1.1","1"],["45","211.077565","2"],["44.24","1","1"],["42","1.020716","1"],["41.86","6.989249","1"],["40","2748.381424","5"],["39","1026.043927","4"],["38.06","20","1"],["38","25.652513","2"],["36","0.069883","1"],["35.51","1","1"],["35","118.299592","2"],["34.8","30.632357","1"],["33.5","20.576417","1"],["33.3","47.050058","1"],["33","30","1"],["32.32","20","1"],["32.16","15","1"],["32","40","1"],["31.8","8","1"],["31","3","1"],["30.1","10","1"],["30","9","3"],["29.86","0.415827","1"],["26.66","5.02157","1"],["25.37","0.05","1"],["25","0.08","1"],["24.68","46","1"],["24.43","15","1"],["23.8","3","1"],["23.66","5.658285","1"],["21.59","1","1"],["20","120.734435","4"],["15","20","1"],["14","10","1"],["12.5","268.766052","1"],["12","0.02","1"],["11","5.5","1"],["10","51.1","3"],["8","2","1"],["5.3","0.09433962","1"],["5","100","1"],["1.68","10","1"],["1.637","50","1"],["1.2","1.5","1"],["1.1","100","1"],["1.01","5","1"],["1","123.3863","7"],["0.84","306.357142","1"],["0.8","2","1"],["0.6","3","1"],["0.55","100","1"],["0.53","0.94339623","1"],["0.5","4","1"],["0.38","30","1"],["0.3","8","1"],["0.2","35","2"],["0.1637","500","1"],["0.151","16","1"],["0.11","106.886128","1"],["0.1","3277.67975","12"],["0.08","123.580625","1"],["0.06","100","1"],["0.05","617.3712","3"],["0.034","147.058823","1"],["0.03","10089","3"],["0.02","14401.394626","8"],["0.015","1000","1"],["0.0128","1188","1"],["0.011","2200","2"],["0.01","10300.254042","17"],["0.005","2575.1222","2"],["0.0031","30","1"],["0.003","32","2"],["0.0021","30","1"],["0.002","3050","4"],["0.001","17900.5","6"],["0.0009","200","1"],["0.0005","600","1"],["0.0003","333.333333","1"],["0.0002","75011","2"],["0.0001","1103.85571381","3"]],"timestamp":"2020-05-06T11:08:30.549Z","checksum":882052922}]}';
//$update = '{"table":"futures/depth","action":"update","data":[{"instrument_id":"DASH-USDT","asks":[["80.5","0","0"],["2000","6.004968","2"]],"bids":[["80.04","22.210533","2"]],"timestamp":"2020-05-06T11:08:30.651Z","checksum":935914430}]}';

//$partial = '{"table":"futures/depth","action":"partial","data":[{"instrument_id":"DASH-USDT","asks":[["80.16","4.928682","1"],["80.17","31.397567","1"],["80.18","4.359814","2"],["80.2","143.912724","8"],["80.22","0.54","3"],["80.24","15.77","1"],["80.27","9.002357","1"],["80.28","34.15","2"],["80.29","7.541","1"],["80.3","65.833228","3"],["80.34","46.78","2"],["80.39","59.82","1"],["80.4","52.469781","2"],["80.41","0.12475","1"],["80.44","4.42214","1"],["80.49","3.092","1"],["80.61","295.07","1"],["80.62","6.296758","2"],["80.69","6.1221","1"],["80.8","4.606","1"],["80.82","4","1"],["80.87","286.41","1"],["80.89","0.312071","1"],["80.94","0.278843","1"],["80.99","9.068862","1"],["81","5.265205","3"],["81.01","10.052636","2"],["81.06","0.75","1"],["81.13","0.00242","1"],["81.16","7.433474","1"],["81.3","1.345","2"],["81.4","19.796","1"],["81.63","3.28","1"],["81.64","13.00242","2"],["81.73","117.7","1"],["81.79","0.278843","1"],["81.8","0.143914","1"],["81.97","4.894327","1"],["81.98","1.0989","1"],["82","4.598","3"],["82.05","3.326","1"],["82.14","0.00242","1"],["82.2","1.2316","1"],["82.31","6.230529","1"],["82.4","24.887796","1"],["82.49","58.36","1"],["82.5","5.779463","2"],["82.64","0.278843","1"],["82.65","0.00242","1"],["82.69","7.670402","1"],["83","2.1","2"],["83.16","0.00242","1"],["83.3","0.143914","1"],["83.49","0.278843","1"],["83.65","6","1"],["83.66","0.00242","1"],["84","113.808912","7"],["84.1","0.143914","1"],["84.17","0.00242","1"],["84.33","0.278843","1"],["84.68","0.00242","1"],["84.8","0.96","1"],["84.9","0.143914","1"],["84.94","68","1"],["85","0.59925","2"],["85.18","0.281263","2"],["85.63","50","1"],["85.69","0.00242","1"],["85.7","0.143914","1"],["85.8","0.2","1"],["86","144.137383","4"],["86.03","0.278843","1"],["86.2","0.00242","1"],["86.32","4.696216","1"],["86.4","0.143914","1"],["86.5","0.238461","1"],["86.58","0.2","1"],["86.68","58.282136","1"],["86.7","0.00242","1"],["86.88","12.402487","2"],["86.94","68","1"],["87","26.384433","3"],["87.2","0.143914","1"],["87.21","0.00242","1"],["87.38","53.110427","1"],["87.42","0.000004","1"],["87.5","1","1"],["87.55","29.982","1"],["87.72","0.00242","1"],["87.73","0.278843","1"],["87.8","0.2","1"],["87.99","0.011005","1"],["88","23.040185","7"],["88.2","0.2","1"],["88.23","0.00242","1"],["88.3","100","1"],["88.33","150","1"],["88.38","48.607454","1"],["88.44","0.283526","1"],["88.5","1","1"],["88.58","0.278843","1"],["88.68","13","1"],["88.73","0.00242","1"],["88.8","0.143914","1"],["88.9","1","1"],["89","69.847826","6"],["89.24","0.00242","1"],["89.43","0.278843","1"],["89.6","0.143914","1"],["89.75","0.00242","1"],["89.8","100","1"],["89.83","130.68604","1"],["90","53.544827","9"],["90.25","0.00242","1"],["90.28","0.278843","1"],["90.3","0.143914","1"],["90.33","0.387997","1"],["90.76","0.00242","1"],["91.1","0.143914","1"],["91.13","0.278843","1"],["91.27","0.00242","1"],["91.77","0.00242","1"],["91.78","0.50324","1"],["91.88","0.2","1"],["91.9","0.143914","1"],["91.98","0.278843","1"],["92","44.105216","2"],["92.28","0.00242","1"],["92.7","0.143914","1"],["92.79","0.00242","1"],["92.83","0.278843","1"],["93","0.1","1"],["93.29","0.00242","1"],["93.5","0.143914","1"],["93.56","48.607454","1"],["93.67","0.278843","1"],["93.8","0.00242","1"],["94.2","0.143914","1"],["94.31","0.00242","1"],["94.52","0.278843","1"],["94.6","11.841718","1"],["94.82","0.00242","1"],["95","65.760473","11"],["95.32","0.00242","1"],["95.37","0.278843","1"],["95.58","0.2","1"],["95.8","0.143914","1"],["95.83","0.00242","1"],["96","6.321769","3"],["96.22","0.278843","1"],["96.34","0.00242","1"],["96.6","0.143914","1"],["96.84","0.00242","1"],["97","4.987651","1"],["97.07","0.278843","1"],["97.35","0.00242","1"],["97.4","0.143914","1"],["97.86","0.00242","1"],["97.92","0.278843","1"],["98","0.164617","2"],["98.1","0.143914","1"],["98.36","0.00242","1"],["98.77","0.278843","1"],["98.87","0.00242","1"],["98.88","1.5","1"],["98.9","0.143914","1"],["99","27.131918","4"],["99.18","0.23","1"],["99.38","0.00242","1"],["99.62","0.278843","1"],["99.67","14.677918","1"],["99.7","0.143914","1"],["99.89","0.00242","1"],["100","174.424568","5"],["100.47","0.278843","1"],["100.5","0.143914","1"],["101.2","0.143914","1"],["101.32","0.278843","1"],["101.5","0.1","1"],["102","9.218081","3"],["102.16","0.278843","1"],["102.8","0.143914","1"],["103","0.864121","1"],["103.01","0.278843","1"],["103.58","0.233095","1"],["103.6","0.143914","1"],["103.86","0.278843","1"],["104.4","0.143914","1"],["104.5","46","1"],["104.71","0.278843","1"],["105","0.13","2"],["105.1","0.143914","1"],["105.56","0.278843","1"],["105.9","0.143914","1"],["106.41","0.278843","1"],["106.6","0.71","1"],["106.7","0.143914","1"],["107.26","0.278843","1"],["107.5","0.143914","1"],["108","2.704054","2"],["108.11","0.278843","1"],["108.3","0.143914","1"],["108.96","0.278843","1"],["109","0.238914","2"],["109.5","0.026663","1"],["109.8","0.143914","1"],["109.81","0.278843","1"],["110","24.155889","6"],["110.6","0.143914","1"],["110.66","0.278843","1"],["111.1","0.023478","1"],["111.4","0.143914","1"],["111.5","0.278843","1"],["112.2","0.143914","1"],["112.33","0.625","1"],["112.35","0.278843","1"],["112.8","0.09","1"],["112.9","0.143914","1"],["113","0.79288","2"],["113.2","0.278843","1"],["113.7","0.143914","1"],["114.05","0.278843","1"],["114.5","0.143914","1"],["114.9","0.278843","1"],["115","0.05","1"],["115.3","0.143914","1"],["115.75","0.278843","1"],["116.1","0.143914","1"],["116.6","0.278843","1"],["116.8","0.143914","1"],["117.45","0.278843","1"],["117.6","0.143914","1"],["118.3","0.278843","1"],["118.4","0.143914","1"],["119.15","0.278843","1"],["119.2","0.143914","1"],["120","0.922757","4"],["123","0.81","1"],["123.9","0.999","1"],["125","0.853335","2"],["126","0.260376","1"],["128","3","1"],["128.55","40","1"],["128.61","40","1"],["128.66","40","1"],["128.73","40","1"],["129.5","10","1"],["130","94.997821","9"],["131","0.280357","2"],["132","0.0999","1"],["133","1","1"],["134.9","8.541656","1"],["135","50.5495","3"],["136","0.813","1"],["138","10.178775","4"],["138.5","0.5","1"],["139","5.008541","1"],["139.8","0.1","1"],["140","36.020707","4"],["140.6","0.223875","1"],["141","21.554353","2"],["142","0.0896","1"],["142.68","10","1"],["144.5","0.512654","1"],["145","0.0981","1"],["145.5","26.426977","1"],["145.6","10.953372","1"],["147.7","0.021197","1"],["148.5","0.303406","1"],["149.9","73.134346","1"],["150","73.58562","6"],["150.9","4.394349","1"],["153.2","0.721271","1"],["154.8","19","1"],["156","10.991708","1"],["156.4","100","1"],["156.5","110","1"],["156.6","120","1"],["156.7","130","1"],["156.8","140","1"],["156.9","150","1"],["157","160.081834","3"],["157.2","170","1"],["157.6","180","1"],["157.8","66.490339","1"],["158.8","9.99","1"],["159.9","0.655758","1"],["160","1.2376","3"],["160.7","0.999","1"],["163.2","4.995","1"],["164","0.024913","1"],["165.4","2.003764","1"],["165.5","0.607431","1"],["168.67","0.035448","1"],["168.8","3.68906","2"],["170","9.488118","4"],["172.2","0.1","1"],["172.26","81.724667","1"],["173.7","2.658525","1"],["178.5","9.324416","1"],["178.8","0.209423","1"],["180","51.673691","3"],["182.9","19","1"],["186","10","1"],["188","5.1705","2"],["188.8","114.802859","2"],["189.8","6","1"],["190","0.608803","2"],["192.1","0.026697","1"],["196","0.359915","1"],["198.8","0.09958","1"],["199","1.059843","2"],["200","7.994215","6"],["201.1","0.079521","1"],["204","19","1"],["213.9","0.026299","1"],["214.9","0.028961","1"],["215.2","0.028474","1"],["217.3","0.170247","1"],["220.7","0.024817","1"],["221.2","0.024715","1"],["240","2.192991","1"],["245","16.046909","1"],["246","1","1"],["253.71","0.05","1"],["258.86","16.830617","1"],["258.88","107.146905","1"],["258.93","4.135088","1"],["258.94","5.994","1"],["260","2.051657","3"],["267.4","13.138961","1"],["269.13","0.012404","1"],["277","0.236488","1"],["280","3.604423","1"],["285","1.310821","1"],["287.2364","0.0811","1"],["300","2.375283","2"],["312.4","0.029171","1"],["313.2","0.044259","1"],["322.1","0.024512","1"],["324.8","0.119831","1"],["327.5","0.023475","1"],["369.6","57.957199","1"],["370","0.189091","1"],["395","0.400551","1"],["399.9999","0.049925","1"],["400","0.5","1"],["404.2734","0.1986","1"],["450","3.112184","2"],["475","1.199428","1"],["479.9999","0.3994","1"],["498.9998","0.063844","1"],["499.9999","0.124813","1"],["500","1.759093","2"],["520","0.253955","3"],["530","0.314802","1"],["555.5","1.998","1"],["560","5.069937","1"],["599.9999","0.063655","1"],["600","50.51065","1"],["610","0.01","1"],["650","0.03","1"],["699.9999","0.253217","1"],["704","0.03","1"],["720","1.984386","1"],["730","5.710593","1"],["735.9999","0.9985","1"],["750","0.089747","2"],["774.85","0.001","1"],["777","0.0775","1"],["800","42.126877","3"],["820.43","2.675089","1"],["888","9.99","1"],["900","0.6","1"],["950","0.06","1"],["999.9","1.220323","1"],["1000","9.210226","4"],["1016.14","0.0802","1"],["1050","2.24375","1"],["1099","0.0558","1"],["1120","0.31167631","2"],["1200","1.279558","3"],["1200.04","27.776688","1"],["1287.7777","0.1321","1"],["1300","5.911316","2"],["1350","0.2","1"],["1400","8.2","1"],["1430","170.271666","2"],["1487.7777","0.179","1"],["1500","0.65182","4"],["1524.212","0.02676792","1"],["1550","2.24375","1"],["1600","0.515502","1"],["1622.2","0.9756","1"],["1680","0.83823488","2"],["1699.9999","0.6304","1"],["1700","1.75044523","1"],["1780","0.503219","1"],["1800","3.24225","2"],["1853","1.00008389","1"]],"bids":[["80.1","0.964417","1"],["80.06","15.79","1"],["80.04","6.502734","1"],["80.02","19.967885","2"],["80.01","3.471295","1"],["80","61.950296","7"],["79.98","13.38","1"],["79.96","7.541","1"],["79.93","7.149232","1"],["79.92","18","1"],["79.9","90.441473","4"],["79.86","59.82","1"],["79.85","0.13","1"],["79.84","0.12525","1"],["79.82","0.13","1"],["79.81","1.78","1"],["79.8","7.469781","1"],["79.76","2.862","1"],["79.66","295.07","1"],["79.65","3.295883","1"],["79.61","0.00242","1"],["79.57","6.178","1"],["79.53","4.164626","1"],["79.42","0.311915","1"],["79.41","3.777861","1"],["79.4","0.143914","1"],["79.37","286.41","1"],["79.34","7.13405","1"],["79.31","8.823778","1"],["79.28","1.7","1"],["79.24","0.278843","1"],["79.22","4","1"],["79.2","7.326797","2"],["79.1","0.00242","1"],["79","1.3","1"],["78.99","8.33223","1"],["78.86","27.200101","1"],["78.85","1.006","1"],["78.77","181.55","1"],["78.7","0.143914","1"],["78.59","0.00242","1"],["78.39","0.278843","1"],["78.36","1.788","1"],["78.26","0.089957","1"],["78.09","0.00242","1"],["78.06","2","1"],["78","8.850058","3"],["77.96","117.7","1"],["77.9","0.143914","1"],["77.8","0.090488","1"],["77.76","21.085842","1"],["77.62","58.36","1"],["77.58","0.00242","1"],["77.54","0.278843","1"],["77.4","27.53438","1"],["77.1","23.224109","2"],["77.07","0.00242","1"],["77","2.3","2"],["76.8","23.770156","1"],["76.69","0.278843","1"],["76.6","50","1"],["76.57","0.00242","1"],["76.49","6.367398","1"],["76.46","35","1"],["76.3","26.886561","2"],["76.06","2.00242","2"],["76","3.85","4"],["75.84","0.278843","1"],["75.68","60","1"],["75.55","0.00242","1"],["75.5","0.143914","1"],["75.48","100","1"],["75.44","58.27","1"],["75.04","0.00242","1"],["75","16.703323","8"],["74.8","0.143914","1"],["74.54","0.00242","1"],["74.3","47.733782","2"],["74.1","26.012145","1"],["74.06","2","1"],["74.03","0.00242","1"],["74","1.143914","2"],["73.84","1.102994","1"],["73.52","0.00242","1"],["73.5","1.749827","1"],["73.3","50","1"],["73.2","0.143914","1"],["73.02","0.00242","1"],["73","11.369642","3"],["72.7","67.976731","1"],["72.51","0.00242","1"],["72.4","0.143914","1"],["72.1","5.988593","1"],["72","21.444831","4"],["71.78","28.221946","1"],["71.6","0.143914","1"],["71.56","57.198854","1"],["71.5","0.00242","1"],["70.99","0.00242","1"],["70.9","0.143914","1"],["70.48","0.00242","1"],["70.2","5.844108","1"],["70.1","0.143914","1"],["70","9.126525","3"],["69.98","0.00242","1"],["69.7","1.5","1"],["69.47","0.00242","1"],["69.3","0.143914","1"],["69","32.706271","2"],["68.96","0.00242","1"],["68.8","3","1"],["68.6","0.619388","1"],["68.5","0.143914","1"],["68.45","0.00242","1"],["67.95","0.00242","1"],["67.7","73.141082","2"],["67.5","8.024837","1"],["67.44","0.00242","1"],["67","1.143914","2"],["66.93","0.00242","1"],["66.43","0.00242","1"],["66.2","0.143914","1"],["66","82.115676","2"],["65.92","0.00242","1"],["65.41","0.00242","1"],["65.4","0.143914","1"],["65","0.6","2"],["64.91","0.00242","1"],["64.6","0.143914","1"],["64.4","0.00242","1"],["63.89","0.00242","1"],["63.8","0.143914","1"],["63.4","0.006135","1"],["63.39","0.00242","1"],["63.1","0.143914","1"],["62.88","0.00242","1"],["62.37","0.00242","1"],["62.3","0.143914","1"],["61.86","0.00242","1"],["61.8","1.7","1"],["61.5","0.143914","1"],["61.4","46","1"],["61.36","0.00242","1"],["60.85","0.00242","1"],["60.7","0.143914","1"],["60.5","1","1"],["60.34","0.00242","1"],["60.1","18.420849","1"],["60","10.62293","2"],["59.84","0.00242","1"],["59.33","0.00242","1"],["59","0.039068","1"],["58.82","0.00242","1"],["58.32","0.00242","1"],["57.81","0.00242","1"],["57.64","0.02","1"],["57.3","0.00242","1"],["57","0.054829","1"],["56.8","0.00242","1"],["56.29","0.00242","1"],["55.78","0.00242","1"],["55.58","11.95629","1"],["55.27","0.00242","1"],["55","13.669101","2"],["54.77","0.00242","1"],["54.6","2","1"],["54.26","0.00242","1"],["53.75","0.00242","1"],["53.25","0.00242","1"],["53","0.042895","1"],["52.74","0.00242","1"],["52.66","30.015","1"],["52.23","0.00242","1"],["51.8","5","1"],["51.73","0.00242","1"],["51.22","0.00242","1"],["50.71","0.00242","1"],["50.21","0.00242","1"],["50","43.565003","6"],["49.11","530.114857","1"],["46.5","5","1"],["45.5","1.1","1"],["45","211.077565","2"],["44.24","1","1"],["42","1.020716","1"],["41.86","6.989249","1"],["40","2748.381424","5"],["39","1026.043927","4"],["38.06","20","1"],["38","25.652513","2"],["36","0.069883","1"],["35.51","1","1"],["35","118.299592","2"],["34.8","30.632357","1"],["33.5","20.576417","1"],["33.3","47.050058","1"],["33","30","1"],["32.32","20","1"],["32.16","15","1"],["32","40","1"],["31.8","8","1"],["31","3","1"],["30.1","10","1"],["30","9","3"],["29.86","0.415827","1"],["26.66","5.02157","1"],["25.37","0.05","1"],["25","0.08","1"],["24.68","46","1"],["24.43","15","1"],["23.8","3","1"],["23.66","5.658285","1"],["21.59","1","1"],["20","120.734435","4"],["15","20","1"],["14","10","1"],["12.5","268.766052","1"],["12","0.02","1"],["11","5.5","1"],["10","51.1","3"],["8","2","1"],["5.3","0.09433962","1"],["5","100","1"],["1.68","10","1"],["1.637","50","1"],["1.2","1.5","1"],["1.1","100","1"],["1.01","5","1"],["1","123.3863","7"],["0.84","306.357142","1"],["0.8","2","1"],["0.6","3","1"],["0.55","100","1"],["0.53","0.94339623","1"],["0.5","4","1"],["0.38","30","1"],["0.3","8","1"],["0.2","35","2"],["0.1637","500","1"],["0.151","16","1"],["0.11","106.886128","1"],["0.1","3277.67975","12"],["0.08","123.580625","1"],["0.06","100","1"],["0.05","617.3712","3"],["0.034","147.058823","1"],["0.03","10089","3"],["0.02","14401.394626","8"],["0.015","1000","1"],["0.0128","1188","1"],["0.011","2200","2"],["0.01","10300.254042","17"],["0.005","2575.1222","2"],["0.0031","30","1"],["0.003","32","2"],["0.0021","30","1"],["0.002","3050","4"],["0.001","17900.5","6"],["0.0009","200","1"],["0.0005","600","1"],["0.0003","333.333333","1"],["0.0002","75011","2"],["0.0001","1103.85571381","3"]],"timestamp":"2020-05-06T11:26:11.842Z","checksum":-1260061024}]}';
//$update = '{"table":"futures/depth","action":"update","data":[{"instrument_id":"DASH-USDT","asks":[],"bids":[["80.02","17.8","1"],["80","73.111192","9"],["79.9","90.12","3"]],"timestamp":"2020-05-06T11:26:11.945Z","checksum":-1948075244}]}';

$partial = '{"arg":{"channel":"books","instId":"BTC-USDT"},"action":"snapshot","data":[{"asks":[["22822.1","41.54452305","0","1"],["22822.7","32.6473686","0","1"],["22823.3","47.06321946","0","1"],["22823.4","20.82013888","0","1"],["22823.8","45.21696911","0","1"],["22824.3","30.7444336","0","1"],["22825.2","48.35778331","0","1"],["22826.2","36.58973609","0","1"],["22826.6","19.34936121","0","1"],["22826.7","14.16100876","0","1"],["22827.1","45.2444105","0","1"],["22827.8","49.35138411","0","1"],["22828.3","12.69153814","0","1"],["22828.6","20.83146606","0","1"],["22829.1","12.75807402","0","1"],["22829.4","40.28631809","0","1"],["22830.2","21.05696588","0","1"],["22831","10.22412789","0","1"],["22831.9","14.74647263","0","1"],["22832.9","11.53250535","0","1"],["23099","0.001","0","1"],["23270","0.1","0","1"],["24000","1","0","1"],["25001","3.998","0","1"],["226000.5","1.88737145","0","1"],["99999999","2.02512819","0","1"],["100000000","9.89973729","0","1"]],"bids":[["22822","23.18698199","0","1"],["22821.9","29.5174736","0","1"],["22821.7","39.75248639","0","1"],["22820.4","44.48121914","0","1"],["22819","24.85246781","0","1"],["22818.9","24.1212152","0","1"],["22818.7","32.07118355","0","1"],["22818","33.30050008","0","1"],["22817.5","35.99015469","0","1"],["22817.3","16.16676912","0","1"],["22817.1","44.95706965","0","1"],["22816.3","25.06382497","0","1"],["22815.5","38.64795108","0","1"],["22814.7","38.41274279","0","1"],["22813.8","27.09738297","0","1"],["22813.6","44.96350164","0","1"],["22813.5","23.28824505","0","1"],["22813.2","23.99693189","0","1"],["22812.7","49.82263737","0","1"],["22812.5","34.0001182","0","1"],["19058.6","0.11","0","1"],["15000","1","0","1"],["10000","1","0","1"],["2324","1","0","1"],["2311","8.62816961","0","5"],["1000","0.1","0","1"],["200","1","0","1"],["100","1","0","1"],["29","99","0","1"],["26","9","0","1"],["12","1","0","1"],["11.3","1269.91150442","0","1"],["8","625","0","1"],["3","5","0","1"],["2.1","2","0","1"],["1","28006.1","0","8"]],"ts":"1608289926423","checksum":1959072422}]}';
$update = '{"arg":{"channel":"books","instId":"BTC-USDT"},"action":"update","data":[{"asks":[["22822.1","0.2720133","0","1"]],"bids":[],"ts":"1608289927396","checksum":3180175}]}';

$checksum = new ChecksumTest();

$partial = $checksum->depthMerge($partial,$update);
$state = $checksum->checkSum($partial);



// java
//$partial = '{"table":"futures/depth","action":"partial","data":[{"instrument_id":"BSV-USD-190816","asks":[["123.97","40","0"],["124.0","24","0"],["124.03","96","0"],["124.06","96","0"],["124.12","2","0"],["124.13","3","0"],["124.14","1645","0"],["124.19","250","0"],["124.21","10","0"],["124.22","10","0"],["124.23","240","0"],["124.25","10","0"],["124.31","66","0"],["124.4","233","0"],["124.45","360","0"],["124.5","757","0"],["124.59","865","0"],["124.75","960","0"],["124.8","2000","0"],["125.06","1522","0"],["125.09","1080","0"],["125.16","1230","0"],["125.3","121","0"],["125.33","30","0"],["125.44","144","0"],["125.7","5839","0"],["126.21","3528","0"],["127.15","2469","0"],["128.08","1189","0"],["131.0","515","0"],["138.3","64","0"],["138.31","128","0"],["138.33","128","0"],["141.37","128","0"],["142.37","64","0"],["142.9","64","0"],["144.43","106","0"],["144.46","20","0"],["144.86","185","0"],["145.29","187","0"],["145.72","239","0"],["146.15","101","0"],["146.58","228","0"],["147.01","299","0"],["147.45","297","0"],["147.89","283","0"],["148.33","223","0"],["148.77","278","0"],["149.21","129","0"],["149.65","269","0"],["150.09","128","0"],["150.16","20","0"],["150.54","124","0"],["150.99","134","0"],["151.44","213","0"],["151.89","195","0"],["152.34","116","0"],["152.79","224","0"],["153.24","290","0"],["153.69","202","0"],["154.15","243","0"],["154.61","286","0"],["155.07","126","0"],["155.53","185","0"],["155.99","167","0"],["156.45","204","0"],["156.46","64","0"],["156.91","191","0"],["157.38","244","0"],["157.85","249","0"],["158.32","234","0"],["158.79","236","0"],["159.26","163","0"],["159.73","273","0"],["160.0","1","0"],["160.2","106","0"],["160.21","264","0"],["160.69","187","0"],["161.17","125","0"],["161.66","253","0"],["165.0","1","0"],["169.0","1","0"]],"bids":[["123.66","44","0"],["123.62","6","0"],["123.53","364","0"],["123.49","2","0"],["123.44","24","0"],["123.43","120","0"],["123.42","24","0"],["123.39","231","0"],["123.37","96","0"],["123.35","96","0"],["123.23","16","0"],["123.21","240","0"],["123.19","2046","0"],["123.14","90","0"],["123.04","1230","0"],["122.97","360","0"],["122.96","196","0"],["122.9","360","0"],["122.89","2000","0"],["122.8","1385","0"],["122.6","480","0"],["122.59","480","0"],["122.58","5839","0"],["122.34","30","0"],["122.06","3529","0"],["121.76","2470","0"],["121.64","64","0"],["121.11","64","0"],["120.83","1190","0"],["120.55","159","0"],["118.36","142","0"],["114.0","10","0"],["104.76","202","0"],["104.45","213","0"],["104.14","160","0"],["103.82","138","0"],["103.5","282","0"],["103.18","159","0"],["102.87","106","0"],["102.56","189","0"],["102.25","161","0"],["101.94","197","0"],["101.63","117","0"],["101.32","145","0"],["101.01","288","0"],["100.7","149","0"],["100.39","193","0"],["100.08","271","0"],["99.77","273","0"],["99.47","233","0"],["99.17","147","0"],["98.87","122","0"],["98.57","149","0"],["98.27","205","0"],["97.97","102","0"],["97.67","269","0"],["97.37","237","0"],["97.07","235","0"],["96.77","194","0"],["96.47","265","0"],["96.18","102","0"],["95.89","105","0"],["95.6","166","0"],["95.31","195","0"],["95.02","295","0"],["94.73","135","0"],["94.44","291","0"],["94.15","276","0"],["93.86","237","0"],["93.57","104","0"],["93.28","258","0"],["93.0","235","0"]],"timestamp":"2019-08-15T06:45:25.258Z","checksum":174965541}]}';
// php
//$partial = '{"table":"futures/depth","action":"partial","data":[{"instrument_id":"BCH-USD-191227","asks":[["297.79","180","0","2"],["297.83","100","0","1"],["297.84","1134","0","4"],["297.87","1","0","1"],["297.88","190","0","2"],["297.91","52","0","2"],["297.92","88","0","2"],["297.96","341","0","3"],["297.97","101","0","6"],["297.98","136","0","6"],["297.99","285","0","4"],["298.0","101","0","2"],["298.01","60","0","1"],["298.02","62","0","1"],["298.03","27","0","2"],["298.04","24","0","1"],["298.05","149","0","3"],["298.06","161","0","4"],["298.07","3","0","3"],["298.08","256","0","1"],["298.09","35","0","2"],["298.1","446","0","2"],["298.11","150","0","2"],["298.12","200","0","1"],["298.13","96","0","2"],["298.16","318","0","2"],["298.18","2","0","2"],["298.19","2025","0","3"],["298.2","118","0","2"],["298.21","150","0","1"],["298.23","160","0","1"],["298.25","100","0","1"],["298.26","218","0","2"],["298.28","440","0","1"],["298.32","13","0","1"],["298.33","14","0","2"],["298.34","14","0","2"],["298.35","160","0","1"],["298.36","824","0","4"],["298.37","166","0","2"],["298.38","100","0","1"],["298.4","600","0","1"],["298.42","280","0","1"],["298.44","550","0","3"],["298.45","713","0","4"],["298.46","170","0","1"],["298.47","505","0","2"],["298.48","643","0","2"],["298.49","640","0","1"],["298.5","26","0","2"],["298.51","220","0","1"],["298.52","6879","0","2"],["298.53","640","0","1"],["298.55","60","0","1"],["298.56","100","0","1"],["298.57","225","0","1"],["298.6","484","0","3"],["298.61","231","0","2"],["298.62","280","0","1"],["298.63","525","0","3"],["298.66","3030","0","1"],["298.68","26","0","2"],["298.7","87","0","1"],["298.71","634","0","2"],["298.72","664","0","4"],["298.74","225","0","1"],["298.76","872","0","4"],["298.77","352","0","1"],["298.78","225","0","1"],["298.79","102","0","1"],["298.83","1055","0","2"],["298.85","6","0","1"],["298.87","13","0","1"],["298.88","132","0","1"],["298.89","1025","0","5"],["298.9","127","0","1"],["298.93","3","0","1"],["298.96","127","0","1"],["299.0","10","0","1"],["299.02","960","0","1"],["299.06","960","0","1"],["299.08","300","0","2"],["299.1","960","0","1"],["299.15","3042","0","2"],["299.19","2999","0","1"],["299.2","3000","0","1"],["299.23","9038","0","3"],["299.27","2903","0","1"],["299.3","17","0","1"],["299.36","3694","0","1"],["299.38","3","0","1"],["299.42","88","0","1"],["299.53","300","0","2"],["299.55","547","0","1"],["299.6","29","0","1"],["299.67","1280","0","1"],["299.7","2480","0","2"],["299.82","3","0","1"],["299.85","1280","0","1"],["299.86","25","0","1"],["299.9","14","0","1"],["299.98","6355","0","2"],["300.0","3376","0","9"],["300.01","66","0","1"],["300.12","750","0","1"],["300.22","3639","0","1"],["300.26","35","0","1"],["300.27","3","0","1"],["300.47","6001","0","1"],["300.5","1616","0","1"],["300.71","78","0","1"],["300.72","3","0","1"],["300.96","2440","0","1"],["301.0","1344","0","3"],["301.16","3","0","1"],["301.37","2","0","1"],["301.51","120","0","1"],["301.53","603","0","1"],["301.54","20","0","1"],["301.57","1999","0","1"],["301.61","4","0","1"],["301.7","250","0","1"],["302.0","147","0","3"],["302.06","4","0","1"],["302.36","33","0","1"],["302.45","1190","0","1"],["302.51","4","0","1"],["302.52","30","0","1"],["302.65","4698","0","1"],["302.66","3631","0","1"],["302.72","3999","0","1"],["302.88","614","0","2"],["302.95","4","0","1"],["303.0","2010","0","2"],["303.26","20","0","1"],["303.33","30","0","2"],["303.36","10","0","1"],["303.4","4","0","1"],["303.5","6242","0","2"],["303.66","30","0","1"],["303.8","1494","0","1"],["303.85","4","0","1"],["304.0","3394","0","9"],["304.15","121","0","1"],["304.29","4","0","1"],["304.3","91","0","1"],["304.34","91","0","1"],["304.35","334","0","2"],["304.39","35","0","1"],["304.43","608","0","1"],["304.6","251","0","1"],["304.63","30","0","1"],["304.74","4","0","1"],["304.78","13","0","1"],["304.8","2072","0","2"],["304.92","30","0","1"],["305.0","1953","0","9"],["305.19","4","0","1"],["305.2","30","0","1"],["305.48","2160","0","2"],["305.5","2430","0","4"],["305.63","5","0","1"],["305.76","30","0","1"],["305.9","30","0","1"],["306.0","1625","0","5"],["306.04","30","0","1"],["306.08","5","0","1"],["306.13","30","0","1"],["306.16","73","0","1"],["306.18","30","0","1"],["306.32","30","0","1"],["306.47","30","0","1"],["306.51","7049","0","1"],["306.53","5","0","1"],["306.61","30","0","1"],["306.62","527","0","1"],["306.75","30","0","1"],["306.89","30","0","1"],["306.98","5","0","1"],["307.0","1101","0","7"],["307.03","30","0","1"],["307.17","30","0","1"],["307.31","30","0","1"],["307.42","5","0","1"],["307.45","830","0","2"],["307.59","4030","0","2"],["307.6","25","0","1"],["307.73","6029","0","2"],["307.76","8","0","1"],["307.87","135","0","3"],["308.0","1957","0","5"],["308.02","30","0","1"],["308.16","30","0","1"],["308.3","30","0","1"],["308.32","6","0","1"],["308.44","30","0","1"],["308.5","123","0","1"],["308.58","30","0","1"],["308.72","49","0","1"],["308.76","6","0","1"]],"bids":[["297.77","375","0","2"],["297.76","13","0","4"],["297.72","400","0","1"],["297.71","76","0","2"],["297.7","10","0","1"],["297.69","36","0","1"],["297.67","26","0","2"],["297.65","298","0","2"],["297.63","22","0","4"],["297.62","40","0","3"],["297.61","35","0","1"],["297.6","12","0","1"],["297.58","542","0","6"],["297.56","58","0","1"],["297.55","64","0","1"],["297.54","127","0","5"],["297.53","274","0","5"],["297.52","37","0","2"],["297.51","128","0","4"],["297.5","133","0","2"],["297.49","28","0","5"],["297.48","53","0","19"],["297.47","115","0","2"],["297.46","90","0","4"],["297.45","150","0","2"],["297.44","60","0","1"],["297.43","61","0","2"],["297.42","2","0","2"],["297.41","514","0","4"],["297.39","75","0","1"],["297.38","70","0","2"],["297.37","346","0","2"],["297.36","26","0","2"],["297.35","440","0","1"],["297.33","140","0","2"],["297.32","35","0","1"],["297.31","100","0","1"],["297.29","300","0","1"],["297.28","4","0","4"],["297.27","166","0","3"],["297.26","600","0","1"],["297.25","90","0","1"],["297.23","575","0","3"],["297.2","92","0","1"],["297.19","800","0","2"],["297.18","27","0","3"],["297.15","100","0","1"],["297.14","30","0","1"],["297.13","1","0","1"],["297.11","1999","0","1"],["297.07","2","0","2"],["297.06","1","0","1"],["297.03","1339","0","3"],["297.01","1","0","1"],["297.0","648","0","2"],["296.99","713","0","3"],["296.98","43","0","3"],["296.97","225","0","1"],["296.9","1196","0","4"],["296.89","520","0","3"],["296.88","1","0","1"],["296.85","170","0","1"],["296.84","205","0","1"],["296.82","102","0","1"],["296.77","13","0","1"],["296.76","6","0","1"],["296.75","280","0","1"],["296.73","232","0","3"],["296.71","898","0","3"],["296.69","8","0","3"],["296.66","10","0","1"],["296.65","102","0","1"],["296.63","225","0","1"],["296.59","1","0","1"],["296.57","1","0","1"],["296.53","963","0","2"],["296.52","960","0","1"],["296.45","6","0","1"],["296.44","1260","0","3"],["296.34","352","0","1"],["296.32","148","0","1"],["296.3","592","0","1"],["296.26","100","0","1"],["296.25","1","0","1"],["296.21","6","0","1"],["296.18","46","0","1"],["296.09","3","0","1"],["296.07","2076","0","1"],["296.05","3000","0","1"],["296.0","99","0","3"],["295.99","300","0","2"],["295.98","3000","0","1"],["295.97","1200","0","1"],["295.94","3000","0","1"],["295.9","2109","0","3"],["295.86","1280","0","1"],["295.82","1280","0","1"],["295.81","2999","0","1"],["295.78","1280","0","1"],["295.64","3","0","1"],["295.6","2000","0","1"],["295.5","6078","0","2"],["295.43","830","0","1"],["295.36","53","0","1"],["295.2","400","0","2"],["295.19","3","0","1"],["295.18","885","0","1"],["295.11","400","0","2"],["295.1","59","0","1"],["295.0","4634","0","19"],["294.99","6001","0","1"],["294.92","29","0","1"],["294.88","10","0","1"],["294.76","86","0","1"],["294.75","3","0","1"],["294.68","1200","0","1"],["294.63","29","0","1"],["294.62","8","0","1"],["294.45","4682","0","1"],["294.44","6043","0","2"],["294.35","294","0","2"],["294.3","61","0","2"],["294.27","300","0","1"],["294.21","735","0","1"],["294.18","147","0","1"],["294.07","29","0","1"],["294.01","1470","0","1"],["294.0","676","0","7"],["293.86","4","0","1"],["293.79","29","0","1"],["293.7","3640","0","1"],["293.66","1468","0","1"],["293.62","176","0","1"],["293.51","29","0","1"],["293.5","833","0","3"],["293.46","14","0","1"],["293.41","4","0","1"],["293.29","5","0","1"],["293.25","2441","0","1"],["293.2","8","0","1"],["293.11","25","0","1"],["293.1","1465","0","2"],["293.08","439","0","1"],["293.04","550","0","1"],["293.01","219","0","1"],["293.0","2164","0","11"],["292.96","6","0","2"],["292.89","20","0","1"],["292.88","2","0","1"],["292.8","268","0","1"],["292.74","1463","0","1"],["292.63","20","0","1"],["292.6","20","0","1"],["292.52","4","0","1"],["292.42","34","0","1"],["292.4","1462","0","1"],["292.27","200","0","1"],["292.07","4","0","1"],["292.01","3999","0","1"],["292.0","584","0","9"],["291.77","8","0","1"],["291.76","1191","0","1"],["291.67","145","0","1"],["291.63","54","0","2"],["291.19","1800","0","1"],["291.18","4","0","1"],["291.0","216","0","8"],["290.99","123","0","1"],["290.88","872","0","1"],["290.8","2","0","1"],["290.79","200","0","1"],["290.73","4","0","1"],["290.69","29","0","1"],["290.66","30","0","1"],["290.62","145","0","1"],["290.6","50","0","1"],["290.56","4","0","1"],["290.5","116","0","1"],["290.35","8","0","1"],["290.29","4","0","1"],["290.1","580","0","1"],["290.02","50","0","1"],["290.0","11908","0","29"],["289.95","2","0","1"],["289.84","5","0","1"],["289.81","434","0","1"],["289.7","1065","0","2"],["289.56","1163","0","2"],["289.4","14","0","1"],["289.39","5","0","1"],["289.2","1446","0","1"],["289.04","5","0","1"],["289.01","3000","0","1"],["289.0","8036","0","7"],["288.95","5","0","1"],["288.94","3000","0","1"],["288.93","14","0","1"],["288.9","3000","0","1"],["288.88","1888","0","3"],["288.86","10","0","1"]],"timestamp":"2019-09-24T10:54:00.856Z","checksum":297727568}]}';
//print_r($partial."\n");
$state = $checksum->checkSum($partial);

//print_r($state);
//$test = "119.95:9.2794:119.96:0.0023:119.94:12.0194:120.01:0.1667:119.92:7.5142:120.02:0.0146:119.91:0.9664:120.09:6.25:119.9:14:120.1:3:119.89:0.1666:120.11:6.4819:119.87:0.012:120.15:5.2697:119.86:6.252:120.16:13.4878:119.84:15.4802:120.19:8.2437:119.83:13.3988:120.21:58.3489:119.82:24.8308:120.22:8.3793:119.81:4.3429:120.23:13.0337:119.8:6.255:120.26:66.699:119.76:33.3316:120.28:13.84:119.75:13.5807:120.32:40:119.74:3:120.34:2.46:119.64:66.6753:120.35:5.055:119.61:34:120.36:4.36:119.59:4.39:120.37:12.9985:119.58:40:120.45:33.999:119.57:17.03:120.47:0.3331:119.54:8.6851:120.49:5.12:119.52:0.243:120.58:0.2:119.51:20:120.64:35.54:119.49:13.0277:120.77:19.534";
//$test = '10198:0.3734423:10198.1:12.21877497:10197.1:1.094:10198.2:0.019:10196.8:0.00196099:10198.5:0.029:10196.7:0.93:10198.6:0.017:10195.9:0.088:10198.9:0.2:10195.8:0.96217826:10199:2:10195.3:0.705:10199.1:0.017:10195.2:0.1:10199.4:0.0019611:10195.1:0.324:10199.5:0.063:10195:1:10199.6:0.4:10194.7:0.0094041:10199.7:0.001:10194.6:0.2:10199.8:1.682:10194.5:1.20161963:10200:0.5:10194:0.04:10200.1:0.50658763:10193.9:0.0019616:10200.3:3.99493844:10193.4:0.05134215:10200.6:0.017:10193.2:0.05:10200.8:1.31780321:10193:0.04904649:10200.9:0.197:10192.9:0.2:10201:0.2:10192.8:0.26903274:10201.3:0.05:10192.5:0.2601525:10201.6:0.45637232:10192.2:1.27452464:10201.7:0.15240005:10192:0.04:10201.8:0.606:10191.6:0.05:10201.9:0.31157305:10191.4:0.04:10202:0.001';
//$test = '10198:0.3734423:10198.1:12.21877497:10197.1:1.094:10198.2:0.019:10196.8:0.00196099:10198.5:0.029:10196.7:0.93:10198.6:0.017:10195.9:0.088:10198.9:0.2:10195.8:0.96217826:10199:2:10195.3:0.705:10199.1:0.017:10195.2:0.1:10199.4:0.0019611:10195.1:0.324:10199.6:0.4:10195:1:10199.7:0.001:10194.7:0.0094041:10199.8:1.682:10194.6:0.2:10199.9:0.003637:10194.5:1.20161963:10200:0.5:10194:0.04:10200.1:0.00658763:10193.9:0.0019616:10200.3:3.99493844:10193.2:0.05:10200.6:0.017:10193:0.04904649:10200.8:1.31780321:10192.9:0.2:10200.9:0.197:10192.8:0.32037489:10201:0.2:10192.5:0.2601525:10201.3:0.05:10192.2:1.27452464:10201.4:0.37833406:10192:0.04:10201.6:0.45637232:10191.6:0.05:10201.7:0.15240005:10191.4:0.04:10201.8:0.606:10191.3:0.34806016:10201.9:0.31157305';
//$test = '10198:0.3734423:10198.1:12.21877497:10197.1:1.094:10198.2:0.019:10196.8:0.00196099:10198.5:0.029:10196.7:0.93:10198.6:0.017:10195.9:0.088:10198.9:0.2:10195.8:0.96217826:10199:2:10195.3:0.705:10199.1:0.017:10195.2:0.1:10199.4:0.0019611:10195.1:0.324:10199.5:0.063:10195:1:10199.6:0.4:10194.7:0.0094041:10199.7:0.001:10194.6:0.2:10199.8:1.682:10194.5:1.20161963:10200:0.5:10194:0.04:10200.1:0.50658763:10193.9:0.0019616:10200.3:3.99493844:10193.4:0.05134215:10200.6:0.017:10193.2:0.05:10200.8:1.31780321:10193:0.04904649:10200.9:0.197:10192.9:0.2:10201:0.2:10192.8:0.26903274:10201.3:0.05:10192.5:0.2601525:10201.6:0.45637232:10192.2:1.27452464:10201.7:0.15240005:10192:0.04:10201.8:0.606:10191.6:0.05:10201.9:0.31157305:10191.4:0.04:10202:0.001';
//$$partial = '{"arg":{"channel":"books","instId":"BTC-USDT"},"action":"snapshot","data":[{"asks":[["22853.8","47.88488362","0","1"],["22855.2","49.36843076","0","1"],["22857.3","46.76408824","0","1"],["22858.2","24.59860109","0","1"],["22858.4","27.17804417","0","1"],["22858.9","15.45661661","0","1"],["22859.7","15.41592125","0","1"],["22860.1","40.19496344","0","1"],["22860.4","13.58851541","0","1"],["22860.8","37.02210684","0","1"],["22861.3","13.33690117","0","1"],["22862.1","39.15634998","0","1"],["22862.8","30.23105688","0","1"],["22864.4","12.38612806","0","1"],["22865.6","31.5627738","0","1"],["22866.1","12.16212085","0","1"],["22866.9","30.18362199","0","1"],["22867.7","14.51356518","0","1"],["22868.7","33.58918709","0","1"],["22869.8","42.01856138","0","1"],["23099","0.001","0","1"],["23270","0.1","0","1"],["24000","1","0","1"],["25001","3.998","0","1"],["226000.5","1.88737145","0","1"],["99999999","2.02512819","0","1"],["100000000","9.89973729","0","1"]],"bids":[["22848.1","33.39327218","0","1"],["22845.4","30.39854874","0","1"],["22844.3","26.08871551","0","1"],["22844.1","12.68699213","0","1"],["22843.9","33.23817166","0","1"],["22843","41.68000598","0","1"],["22842.3","42.26402517","0","1"],["22842","23.3962294","0","1"],["22841.1","29.72499726","0","1"],["22839.3","27.16776266","0","1"],["22837.6","12.49045438","0","1"],["22836.4","31.03300898","0","1"],["22835.1","14.89641821","0","1"],["22833.9","32.10636775","0","1"],["22833","47.1793827","0","1"],["19058.6","0.11","0","1"],["15000","1","0","1"],["10000","1","0","1"],["2324","1","0","1"],["2311","8.62816961","0","5"],["1000","0.1","0","1"],["200","1","0","1"],["100","1","0","1"],["29","99","0","1"],["26","9","0","1"],["12","1","0","1"],["11.3","1269.91150442","0","1"],["8","625","0","1"],["3","5","0","1"],["2.1","2","0","1"],["1","28006.1","0","8"]],"ts":"1608289311419","checksum":-9149361}]}';
////$state = $checksum->getCrc32($partial);
//
if ($state){
    echo "校验成功\n";
//    print_r($partial);
}else{
    echo "校验失败\n";
}

class ChecksumTest{
    /**
     * 校验和
     * @param $partial
     * @return bool
     */
    function checksum($partial){

        $partial = json_decode($partial, true);

        $asks = array_values($partial["data"][0]["asks"]);

        $bids = array_values($partial["data"][0]["bids"]);

        $strs="";
        for ($i=0; $i<25; $i++){
            if (@$bids[$i]){
                $strs.=$bids[$i][0];
                $strs.=":";
                $strs.=$bids[$i][1];
                $strs.=":";
            }

            if (@$asks[$i]){
                $strs.=$asks[$i][0];
                $strs.=":";
                $strs.=$asks[$i][1];
                $strs.=":";
            }
        }

        $strs = substr($strs,0,strlen($strs)-1);

        print_r($strs . "\n");

        $strs = crc32($strs);

        // 计算前25档的checksum
        $strs = $this->get_signed_int($strs);

        switch (true)
        {
            case ($partial["data"][0]["checksum"]==$strs);
                return true;
                break;
            default:
                return false;
                break;
        }
//        print_r("\nchecksum:".$strs);
    }

    /**
     * 深度合并
     * @param $partial
     * @param $update
     * @return false|string
     */
    function depthMerge($partial, $update){

        $partial = json_decode($partial,true);
        $update = json_decode($update,true);

        $ndata = $partial;

        $partialAsks = $partial["data"][0]["asks"];
        $partialBids = $partial["data"][0]["bids"];
        $updateAsks = $update["data"][0]["asks"];
        $updateBids = $update["data"][0]["bids"];

        if (!empty($updateAsks)){

            for ($i=0; $i<count($partialAsks); $i++){
                for($j=0; $j<count($updateAsks); $j++){
                    switch (true){
                        // 如果价格相同
                        case ($updateAsks[$j][0]==$partialAsks[$i][0]);
                            switch (true){
                                // 数量为0删除此深度，数量有变化则替换此数据
                                case ($updateAsks[$j][1] == 0);
                                    unset($ndata["data"][0]["asks"][$i]);
                                    break;
                                // 同价格，不同数量，替换
                                case ($updateAsks[$j][1] != $partialAsks[$i][1]);
                                    $ndata["data"][0]["asks"][$i][1] = $updateAsks[$j][1];
                                    break;
                            }
                            break;
                        // 如何价格不同
                        case (!$this->deep_in_array($updateAsks[$j][0],$ndata["data"][0]["asks"]) and $updateAsks[$j][1] != 0);
                            array_push($ndata["data"][0]["asks"], $updateAsks[$j]);
                            break;
                    }
                }
            }
        }

        if (!empty($updateBids)){

            for ($i=0; $i<count($partialBids); $i++){
                for($j=0; $j<count($updateBids); $j++){
                    switch (true){
                        // 如果价格相同
                        case ($updateBids[$j][0] == $partialBids[$i][0]);
                            switch (true){
                                case ($updateBids[$j][1] ==0);
                                    unset($ndata["data"][0]["bids"][$i]);
                                    break;
                                case ($updateBids[$j][1] != $partialBids[$i][1]);
                                    $ndata["data"][0]["bids"][$i][1] = $updateBids[$j][1];
                                    break;
                            }
                            break;

                        // 如果 价格不同
                        case (!$this->deep_in_array($updateBids[$j][0], $ndata["data"][0]["bids"]) and $updateBids[$j][1] != 0);
                            array_push($ndata["data"][0]["bids"], $updateBids[$j]);
                            break;
                    }
                }
            }
        }

        // asks 从小到大排序
        $askPrices = array_column($ndata["data"][0]["asks"],0);
        array_multisort($askPrices,SORT_ASC,$ndata["data"][0]["asks"]);

        // bids 从大到小排序
        $bidPrices = array_column($ndata["data"][0]["bids"],0);
        array_multisort($bidPrices,SORT_DESC,$ndata["data"][0]["bids"]);

        // 换 checksum
        $ndata["data"][0]["checksum"] = $update["data"][0]["checksum"];

//        print_r(json_encode($ndata));
        return json_encode($ndata);
    }

    /**
     * 获取32位校验码
     * @param $in
     * @return float|int
     */
    protected function get_signed_int($in) {
        $int_max = pow(2, 31)-1;
        if ($in > $int_max){
            $out = $in - $int_max * 2 - 2;
        }
        else {
            $out = $in;
        }
        return $out;
    }

    /**
     * // 数组的深度搜索
     * @param $value
     * @param $array
     * @return bool
     */
    protected function deep_in_array($value, $array) {
        foreach($array as $item) {
            if (!is_array($item)) {
                if ($item == $value) {
                    return true;
                } else {
                    continue;
                }
            }

            if (in_array($value, $item)) {
                return true;
            } else if ($this->deep_in_array($value, $item)) {
                return true;
            }
        }

        return false;
    }

    public function getCrc32($strs){

        $strs = crc32($strs);

        // 计算前25档的checksum
        $strs = $this->get_signed_int($strs);

        print_r($strs);
        print_r("\n");
    }
}
